<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发送 AJAX 请求</title>
    <script src="../../src/axios/index.js"></script>
</head>
<body>
    <script>
        //函数
        // axios({
        //     //请求的类型
        //     method: 'POST',
        //     //请求的url
        //     url: 'https://api.apiopen.top/getJok',
        //     //url参数
        //     params: {
        //         a:100,
        //         b:200
        //     },
        //     //请求体
        //     data: {
        //         c:300,
        //         d:400
        //     }
        // }).then(response => {
        //     console.log(response);
        // }).catch(reason => {
        //     console.log(reason);
        // })

        // //调用对象方法
        axios.get('https://api.apiopen.top/getJoke', {
            params: {
                a:100,
                b:200
            }
        }).then(response => {
            console.log(response);
        });

        axios.post('https://api.apiopen.top/getJoke', {
            params: {
                a:100,
                b:200
            },
            data: {
                c:300,
                d: 400
            }
        }).then(response => {
            console.log(response);
        });

        axios.put('https://api.apiopen.top/getJoke', {
            params: {
                a:100,
                b:200
            }
        }).then(response => {
            console.log(response);
        });

        axios.delete('https://api.apiopen.top/getJoke', {
            params: {
                a:100,
                b:200
            }
        }).then(response => {
            console.log(response);
        });
    </script>
</body>
</html>